package com.cjk.console.ctrl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cjk.console.request.StbLogRequest;
import com.cjk.console.service.AppService;
import com.cjk.console.service.LogService;
import com.cjk.foundation.commons.response.PageResponse;
import com.cjk.foundation.commons.response.Response;

@Controller
@RequestMapping("/app")
public class AppController {

	@Autowired
	private LogService logService;
	
	@Autowired
	private AppService appService;
	
	@ResponseBody
	@RequestMapping(value = "/stbLog.do", method = RequestMethod.POST)
	public Response stbLog(@RequestBody StbLogRequest request) {
		return appService.stbLog(request);
	}
	
	@ResponseBody
	@RequestMapping(value = "/setTenant.do", method = RequestMethod.POST)
	public Response setTenant(@RequestBody StbLogRequest request) {
		appService.setTenant(request.getSn(), request.getTenantName());
		return Response.success();
	}
	
	@ResponseBody
	@RequestMapping(value = "/getWatchLogList.do", method = RequestMethod.POST)
	public PageResponse getWatchLogList(@RequestBody StbLogRequest request) {
		return logService.getWatchLogList(request, null);
	}
	
	@ResponseBody
	@RequestMapping(value = "/getTenant.do", method = RequestMethod.POST)
	public Response getTenant(@RequestBody StbLogRequest request) {
		return appService.getTenant(request.getSn());
	}
	
}
